 function Time(){
		var now = new Date();
		this.year =  now.getFullYear();
		this.month =  now.getMonth();
		this.date =  now.getDate();
		this.day =  now.getDay();
		this.hour =  now.getHours();
		this.minute =  now.getMinutes();
		this.second =  now.getSeconds();
		this.millisecond =  now.getMilliseconds();
	};

	var days = [
		 'Sun',
		 'Mon',
		 'Tue',
		 'Wed',
		 'Thu',
		 'Fri',
		 'Sat'
	 ];

	var months = [
		 'Jan',
		 'Feb',
		 'Mar',
		 'Apr',
		 'May',
		 'Jun',
		 'Jul',
		 'Aug',
		 'Sep',
		 'Oct',
		 'Nov',
		 'Dec'
	 ];


	Time.prototype.display = function(tar){
		if (tar == 'time'){
			var hr = this.hour;
			var sec = this.second;
			var min = this.minute;

			if (hr > 12)
				hr -= 12;
			else if(hr == 0)
				hr = 12;

			if (sec < 10)
				sec = '0'+ sec;

			if (min < 10)
				 min = '0'+ min;

			return ''+hr+' : '+min+' : '+sec+''
		}

		if (tar == 'date'){
			var mo = this.month;
			var date = this.date;
			var day = this.day;

			return ''+days[day]+' '+months[mo]+' '+date+''
		}
	}

	function display(disp){
		var time = new Time();
		return time.display(disp);
	}

//Clock Object
	var clockInterval;
	var clock = new Object();
	clock.display = function(){
		var time = new Time();
		return time.display('time');
	}

	clock.update = function(){
		$('.time').text(clock.display()+'');
		clockInterval = setTimeout(clock.update, 500);
	}

	clock.update();

//Calendar object
	var calInterval;
	var calDate = new Object();
	calDate.display = function(){
		var time = new Time();
		return time.display('date');
	}

	calDate.update = function(){
		$('.date').text(calDate.display()+'');
		calInterval = setTimeout(calDate.update, 1000);
	}

	calDate.update();

//Time Control
	function TimeMachine(){
		this.time = new Time();
	}

//DOM
	$.fn.center = function(){
		var h = Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop());

		var w = Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft());

		this.css({
			position: 'absolute',
			left: w +'px',
			top: h +'px'
		});
	}

	function caret(){
		$('.caret').fadeToggle({
			duration: 300
		});
		setTimeout (caret, 450);
	}

	$('.clock').center();
	caret();

